//
//  GlobalData.m
//  huhu
//
//  Created by gullmei on 15/10/25.
//  Copyright © 2015年 gullmei. All rights reserved.
//

#import "GlobalData.h"
static GlobalData * g_Data = nil;

@implementation GlobalData
@synthesize adverList = _adverList;
@synthesize account = _account;
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;

+(GlobalData *)GetInstance
{
    @synchronized(self)
    {
        if(g_Data == nil)
        {
            g_Data = [[GlobalData alloc] init];
        }
    }
    return g_Data;
}
-(id)init
{
    if(self = [super init])
    {
        _adverList =[[NSMutableArray alloc] init];

    }
    return  self;
}
- (NSString *)getUserLatitude {
    if (!_latitude || _latitude.length==0) {
        return @"0";
    }
    return _latitude;
}

- (NSString *)getUserLongitude {
    if (!_longitude || _longitude.length==0) {
        return @"0";
    }
    return _longitude;
}

//数据读取
-(void)ReadData
{
     [self restoreData];
    
      if([_storeDic objectForKey:@"adverList"])
      {
          _adverList = [_storeDic objectForKey:@"adverList"];
      }
    
      //用户相关信息获取方式 仅仅举例
       _account = [_storeDic objectForKey:_userID];
}
//数据保存
-(void)SaveData
{
    //把需要存储的数据放入_storeDic
    [_storeDic setObject:_adverList forKey:@"adverList"];
    [_storeDic setObject:_account forKey:_userID];
   
    [self Save];
}
@end
